package com.tyfspring.aop.aspectj;

import com.tyfspring.aop.Pointcut;
import org.aopalliance.aop.Advice;

/**
 * @Description TODO
 * @Author shallow
 * @Date 2023/4/18 16:03
 */

public class AspectJExpressionPointcutAdvisor implements PointcutAdvisor {

    //切入点
    private AspectJExpressionPointcut pointcut;
    //具体拦截方法,通知
    private Advice advice;
    //表达式
    private String expression;

    public void setExpression(String expression) {
        this.expression = expression;
    }

    public void setAdvice(Advice advice) {
        this.advice = advice;
    }

    @Override
    public Advice getAdvice() {
        return advice;
    }

    @Override
    public Pointcut getPointCut() {
        if (null == pointcut) {
            pointcut = new AspectJExpressionPointcut(expression);
        }
        return pointcut;
    }
}
